#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
int main()
{
	int n, m;
	int arr1[100][100];
	int arr2[100][100];
	int i = 0;
	scanf("%d %d", &n, &m);
	for (i = 0; i < n; i++)
	{
		int j = 0;
		for (j = 0; j < m; j++)
		{
			scanf("%d", &arr1[i][j]);
		}
	}
	for (i = 0; i < n; i++)
	{
		int j = 0;
		for (j = 0; j < m; j++)
		{
			scanf("%d", &arr2[i][j]);
		}
	}
	int sum = 0;
	for (i = 0; i < n; i++)
	{
		int j = 0;
		for (j = 0; j < m; j++)
		{
			if (arr1[i][j] == arr2[i][j])
			{
				sum++;
			}
		}
	}
	if (sum == m * n) printf("Yes\n");
	else              printf("No\n");
}